<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //  0 石头  1 剪刀  2 布
        var people = 0;
        var computer = 0;

        while(true) {
            var p_ = +prompt('请输入剪刀，石头，布');
            var c_ = Math.floor(Math.random() * 3);   //  产生0-1的随机数
            if((c_ == 0 && p_ == 1) || (c_ == 1 && p_ == 2) || (c_ == 2 && p_ == 0)) {
                computer++;
                alert('c:'+c_+'p:'+p_+'电脑赢' + computer)
            }else if((p_ == 0 && c_ == 1) || (p_ == 1 && c_ == 2) || (p_ == 2 && c_ == 0)){
                people++;
                alert('c:'+c_+'p:'+p_+'人类赢：' + people)
            }else{
                alert('c:'+c_+'p:'+p_+'平局')
            }
            if(computer == 2) {
                alert('电脑获胜');
                break;
            }
            if(people == 2) {
                alert('您获胜');
                break;
            }
        }
    </script>
</body>
</html>